#ifndef SCREENTRANSITION_H_
#define SCREENTRANSITION_H_

#include <MAUI/Widget.h>
#include <MAUI/Screen.h>
#include <MAUtil/Environment.h>

enum TransitionType {
	SIDEBYSIDE, REVEALFROMBELOW, MOVEOVERTOP
};

class ScreenTransition: public MAUI::Widget, public MAUtil::TimerListener {
public:
	~ScreenTransition() {
	}
	static void makeTransition(MAUI::Screen* fromScreen,
			MAUI::Screen* toScreen, int direction, int duration,
			TransitionType type = SIDEBYSIDE);
private:
	ScreenTransition() :
		Widget(0, 0, 0, 0, NULL) {
		scrW = EXTENT_X(maGetScrSize());
	}

protected:
	static MAUI::Screen* gScreen;
	static ScreenTransition* gWidget;
	void drawWidget();

	double square_sigmoid(double t);
	void updateAlpha(int now);
	void runTimerEvent();

	MAUI::Screen* toScreen;
	MAUI::Widget* fromMainWidget;
	MAUI::Widget* toMainWidget;
	int duration;
	int direction;
	int start_time;
	int scrW;

	static TransitionType currentType;
	double alpha; //0.0 = fromScreen, 1.0 = toScreen
};

#endif /* SCREENTRANSITION_H_ */

